package com.lifu.yygh.oss.controller;

import com.lifu.yygh.common.result.Result;
import com.lifu.yygh.oss.service.FileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description
 * @Author lifu
 * @Date 2021/5/22 10:53
 */
@Api(tags = "文件上传接口")
@RestController
@RequestMapping(value = "/api/oss/file")
public class FileApiController {
    @Autowired
    private FileService fileService;

    @ApiOperation(value = "上传文件到阿里云oss")
    //上传文件到阿里云oss
    @PostMapping(value = "/fileUpload")
    public Result fileUpload(@RequestParam(value = "certificateImage") MultipartFile multipartFile){
        String url = fileService.upload(multipartFile);
        return Result.ok(url);
    }
}
